const Router = require('koa-router')
const roleRouter = new Router({ prefix: '/roles' })
const {
  verifyAuth
} = require('../middleware/authMiddleware')
const {
  getRoleById,
  createRole,
  getRoleList,
  updateRole,
  removeRoleById,
  giveRights,
  removeRight
} = require('../controller/roleController')
//添加角色
roleRouter.post('/',verifyAuth,createRole)
//获取角色
roleRouter.get('/:id', verifyAuth, getRoleById)
//角色列表
roleRouter.get('/',verifyAuth,getRoleList)
//编辑角色
roleRouter.put('/:id', verifyAuth, updateRole)
//删除角色
roleRouter.delete('/:id', verifyAuth, removeRoleById)
//分配权限
roleRouter.post('/:roleId/rights', verifyAuth, giveRights)
//删除权限
roleRouter.delete('/:roleId/rights/:rightId',verifyAuth,removeRight)
module.exports = roleRouter